function indexSearch(){} indexSearch.prototype = { search : function (text){ if(text == ''){ $('.box-times').show(); return } text = removeDiacritics(text); var regex = new RegExp(text,"ig"); $('.box-times').each(function(){ if( $(this).attr('data-match-home-team').match(regex) || $(this).attr('data-match-visitor-team').match(regex) || $(this).attr('data-match-category').match(regex) || $(this).attr('data-match-city').match(regex) || $(this).attr('data-match-place').match(regex) ){ $(this).show(); $(this).addClass('visible-search'); }else{ $(this).hide(); $(this).removeClass('visible-search'); } }) }, setMatchesForSearch: function(){ const partidas = document.querySelectorAll(".swipe-partida"); const jsonObj = []; partidas.forEach((el) => { mandante = $(el).attr('data-mandante'); visitante = $(el).attr('data-visitante'); campeonato = $(el).attr('data-campeonato'); dataEvento = $(el).attr('data-dataevento'); url = $(el).attr('data-url'); const partida = { 'mandante': mandante, 'visitante': visitante, 'campeonato': campeonato, 'dataEvento': dataEvento, 'url': url }; jsonObj.push(partida); }) localStorage.setItem('partidas', JSON.stringify(jsonObj)); }, searchBar: function(searchBar, searchResult){ const obj = localStorage.getItem('partidas'); const monthNames = ["JAN", "FEV", "MAR", "ABR", "MAI", "JUN", "JUL", "AGO", "SET", "OUT", "NOV", "DEZ"]; searchBar.addEventListener("input", function(event){ const searchTerm = searchBar.value; if(searchTerm.length >= 2){ const filteredObj = Object.entries(JSON.parse(obj)).filter(([key, value]) => { if (value.mandante !== undefined || (value.visitante !== undefined && value.visitante !== '')) { const mandanteMatch = (value.mandante || '').toLowerCase().includes(searchTerm.toLowerCase()); const visitanteMatch = (value.visitante || '').toLowerCase().includes(searchTerm.toLowerCase()); return mandanteMatch || visitanteMatch; } }); if (filteredObj.length > 0) { searchResult.innerHTML = ''; searchResult.style.display = 'block'; filteredObj.forEach(([index, result]) => { let listItem = document.createElement("a"); listItem.classList.add("list-item"); listItem.href = result.url; let match = document.createElement("div"); match.classList.add("filter-match"); let teamsMatch = document.createElement("h2"); let teamsMatchText = document.createTextNode(`${result.mandante} X ${result.visitante}`) teamsMatch.appendChild(teamsMatchText); let tournament = document.createElement("h3"); let tournamentText = document.createTextNode(`${result.campeonato}`) tournament.appendChild(tournamentText); let date = document.createElement("span"); let dateFormated = result.dataEvento.split(" - "); let dayFormated = dateFormated[0].split("|"); let dateText = document.createTextNode(`${dayFormated[0]} ${monthNames[parseInt(dayFormated[1]) - 1]}`); date.appendChild(dateText); searchResult.appendChild(listItem); listItem.appendChild(match); listItem.appendChild(date); match.appendChild(teamsMatch); match.appendChild(tournament); setTimeout(() => { match.style.opacity = 1; }, 100 * index); // Ajuste o valor do atraso conforme necessário }); } else { searchResult.innerHTML = ''; searchResult.style.display = 'block'; let empty = document.createElement("p"); let emptyText = document.createTextNode(`Nenhum resultado encontrado.`); empty.appendChild(emptyText); searchResult.appendChild(empty); } }else{ searchResult.style.display = 'none'; searchResult.innerHTML = ''; } }); searchBar.addEventListener("focusout", function(event){ setTimeout(function() { if($(document.activeElement).is("a")){ return }else{ searchResult.innerHTML = ''; searchResult.style.display = 'none'; } }, 0); }); } } var indexSearch = new indexSearch(); function index(){} index.prototype = { validateTicketsSoldSkin : function (skinId, eventId, isExpressSale) { ajaxLoader.ajaxStart(); $.ajax({ url: '/index/validate-ticket-sold-skin', data: {skinId: skinId, eventId: eventId, isExpressSale: isExpressSale}, method: 'post', dataType: 'json', success: function(json) { ajaxLoader.ajaxStop(); console.log(json.url); if (json.status) { window.location.href = json.url; } window.location.href = json.url } }); } } var index = new index(); function bjjvote(){} bjjvote.prototype = { validaEmail : function(email) { var re = /\S+@\S+\.\S+/; console.log('Chegou no valida'); return re.test(email); }, bjjFightVote : function (skinId, eventId, name, email, fight, fighter) { if(name.length == 0){ $('#validateName').show(); }else{ $('#validateName').hide(); } if(fighter == 0){ $('#validateFighter').show(); }else{ $('#validateFighter').hide(); } if(this.validaEmail(email) != true){ $('#validateMail').show(); }else{ $('#validateFighter').hide(); } if(fighter != 0 && this.validaEmail(email) == true && name.length > 0){ console.log('Chegou no true'); $('#validateFighter').hide(); $('#validateMail').hide(); $.ajax({ url: '/index/bjj-fight-vote', data: {skinId: skinId, eventId: eventId, name: name, fight: fight, email: email, fighter: fighter}, method: 'post', dataType: 'json', success: function(json) { ajaxLoader.ajaxStop(); console.log(json.url); if (json.status) { $('.enquete-sucesso').show(); $('.poll').hide(); $('.poll-form').hide(); $('#bjj-submit').hide(); // window.location.href = json.url; } // window.location.href = json.url } }); } } } var bjjvote = new bjjvote(); function btnLoader(){} btnLoader.prototype = { toggle: function(button) { button.classList.add('button-loading-animation'); button.classList.add('bl-active'); }, start: function(button) { button.classList.add('button-loading-animation'); button.classList.add('bl-active'); let blSpin = document.createElement('i'); blSpin.classList.add('bl-spin'); button.append(blSpin); }, stop: function(button) { button.classList.remove('button-loading-animation'); setTimeout(()=>{ button.classList.remove('bl-active'); document.querySelector('.bl-spin').remove(); }, 300); } } var btnLoader = new btnLoader(); if(elementExists( $('#index-search') )) { $(document).on('input', '#index-search', function(){ indexSearch.search( $(this).val() ); }); $('#index-search').on('click', function(e){ $([document.documentElement, document.body]).animate({ scrollTop: $(".box-white").offset().top - 70 }, 1000); }); } if(elementExists( $('#index-mobile-search') )) { $('.icon-search').on('click', function(){ $('.mobile-search').slideToggle(); }); $('#index-mobile-search').on('click', function(e){ $([document.documentElement, document.body]).animate({ scrollTop: $(".box-white").offset().top - 120 }, 1000); }); $(document).on('input', '#index-mobile-search', function(){ indexSearch.search( $(this).val() ); }); } // Theme settings function toggleTheme(theme = null) { if($('#futebolcard-body').length > 0) { toggleTransitionAll(1000); toggleLoadingScreen(1000); let rootEl = document.querySelector(':root'); let themeIcon = document.querySelector('.toggleTheme i'); hintTheme(); if(rootEl.dataset.theme == 'dark' || theme == 'light') { rootEl.dataset.theme = 'light'; themeIcon.className = 'bi bi-brightness-high'; window.localStorage.setItem('data-theme', 'light'); toggleThemeFromCookies('light'); toggleLogo('light'); } else { rootEl.dataset.theme = 'dark'; themeIcon.className = 'bi bi-moon'; window.localStorage.setItem('data-theme', 'dark'); toggleThemeFromCookies('dark'); toggleLogo('dark'); } } } function toggleTransitionAll(time) { let styleSheet = document.createElement("style"); styleSheet.setAttribute('id', 'transition-all') styleSheet.type = "text/css"; styleSheet.innerText = "* { transition: all 1s; } body { overflow-y: hidden; -webkit-overflow-scrolling: hidden; }"; document.head.appendChild(styleSheet); setTimeout(()=>{document.head.removeChild(styleSheet)}, time); } function toggleLoadingScreen(time) { let loader = document.getElementById('page-loader'); loader.classList.remove('d-none'); setTimeout(() => { loader.classList.add('d-none') }, time) } function toggleThemeFromCookies(theme) { eraseCookie('data-theme'); createCookie('data-theme', theme, 30); } function createCookie(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; } function eraseCookie(name) { createCookie(name,"",-1); } function toggleLogo(theme) { let logoImg = document.querySelector('.logo-container img'); if(theme === 'dark') { logoImg.setAttribute('src', `https://${window.location.hostname}/lib/futebolcard/img/logo-futebolcard.svg`); } else { logoImg.setAttribute('src', `https://${window.location.hostname}/lib/futebolcard/img/logo-extensa-laranja.png`); } } function hintTheme() { let hintEl = document.getElementById(window.innerWidth < 768 ? 'hintThemeMobile' : 'hintTheme'); let tooltipHint = new bootstrap.Tooltip(hintEl, { animation: true, customClass: "hintTheme" }); if (!readCookie('hint-theme')) { tooltipHint.show(); createCookie('hint-theme', true, 30); setTimeout(()=>{ tooltipHint.hide(); }, 10000) } else { tooltipHint.hide(); } } window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => { const systemColorScheme = event.matches ? "dark" : "light"; console.log(systemColorScheme, 'systemcolorscheme'); toggleTheme(systemColorScheme); }); $(document).ready(function(){ $('.afterLoad').fadeOut('fast'); let downloadApp = $('.download_app'); // Verifica se downloadApp existe na tela if(downloadApp.length != 0){ // Animation downloadApp.animate({ bottom: '0px' }, 300, "linear"); downloadApp.find('span').on('click', (e) => { $(e.target).parents().find(downloadApp).hide(); }); let playStoreUrl = "https://play.google.com/store/apps/details?id=futebolcard.futebolcard", appStoreUrl = "https://apps.apple.com/br/app/futebolcard/id1462505010", platform = navigator.platform; if (/mac/i.test(platform)) $(".download_app--url").attr("href", appStoreUrl); else if (/linux/i.test(platform)) $(".download_app--url").attr("href", playStoreUrl); else $(".download_app--url").attr("href", playStoreUrl); } if($('#futebolcard-body').length > 0) { toggleLogo(readCookie('data-theme')); const desktopThemeIcon = document.querySelector('#desktopThemeIcon i'); desktopThemeIcon.addEventListener('mouseover', function() { if (readCookie('data-theme') == 'dark') { this.className = 'bi bi-moon-fill'; } else { this.className = 'bi bi-brightness-high-fill'; } }); desktopThemeIcon.addEventListener('mouseout', function() { if (readCookie('data-theme') == 'dark') { this.className = 'bi bi-moon'; } else { this.className = 'bi bi-brightness-high'; } }); if(readCookie('data-theme') == 'dark') document.querySelector(".toggleTheme i").className = 'bi bi-moon'; if(readCookie('data-theme') == 'dark') desktopThemeIcon.className = 'bi bi-moon'; hintTheme(); } });